{% extends "base.html" %}

{% block content %}

<div>
    <form action="/search/" method="get">
        {% csrf_token %}
        {{form}}
        <input type="submit" value="搜索">
    </form>
</div>

<br>

<div>
    {% for word in how_word %}
    <a href="/search/?csrfmiddlewaretoken=5SRjUKnsbRQD9l8RtuhtiC0H6bIPj0j9Ysfilvf3uzBfWCluUhNqS1tHENAOc3CD&search_name={{word.hot_word}}">{{word.hot_word}}</a>
    {% endfor %}
    <a href="/good_list/">全部商品</a>
</div>

<br>

<div class="good_box">
    <div class="imgBox">
        {% for item in hot_recommend %}
        <a href="/good/{{item.good.id}}"><img class="img-slide" src="{{item.good.p_url}}" alt="forloop.counter"
                                              title="{{item.good.name}}"></a>
        {% endfor %}
    </div>

    <div class="hot_itemBox">
        {% for item in hot_sale %}
        <div class="hot_item">
            <a href="/good/{{item.good.id}}"><img width="200px" src="{{item.good.p_url}}"/></a>
            <p>
                商品名<a href="/good/{{item.good.id}}">{{item.good.name}}</a>
            </p>
            <p>
                售价<a href="/buy/{{item.id}}/"><b>￥{{item.good.price}}</b></a>
            </p>
        </div>
        {% endfor %}
    </div>

</div>

<script type="text/javascript">
    var index=0;
    //改变图片
    function ChangeImg() {
        index++;
        var a=document.getElementsByClassName("img-slide");
        if(index>=a.length) index=0;
        for(var i=0;i<a.length;i++){
            a[i].style.display='none';
        }
        a[index].style.display='block';
    }
    //设置定时器，每隔两秒切换一张图片
    ChangeImg()
    setInterval(ChangeImg,2000);
</script>

{% endblock %}